package com.bysj.service;

import com.bysj.dao.TopicReplyDao;
import com.bysj.entity.TopicReply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class TopicReplyServiceImpl implements TopicReplyService {
    @Autowired
    TopicReplyDao topicReplyDao;
    //插入帖子评论
    @Override
    public void addTopicReply(TopicReply topicReply) {
        SimpleDateFormat fmt= new SimpleDateFormat("yyyy-MM-dd");
        Date currentTime = new Date();
        String dateString = fmt.format(currentTime);
        topicReply.setReplydate(dateString);
        topicReplyDao.addTopicReply(topicReply);
    }
    //查询当前贴子的所有评论
    @Override
    public List<TopicReply> getTopicReplyById(Integer id) {
        return topicReplyDao.getTopicReplyById(id);
    }
    //根据id删除评论
    @Override
    public void deleteReplyById(Integer id) {
        topicReplyDao.deleteReplyById(id);
    }
}
